const fs = require('fs')

 function fsPromise(type,filepath,text) {
     if (type === fs.readFile){
         return new Promise((resolve,reject) => {
             fs.readFile(filepath,'utf8',(err,data) => {
                 err ? reject(err) : resolve (data)
             })
         })
     }
     if (type === fs.writeFileSync ){
         return new Promise((resolve,reject)=>{
            fs.writeFile(filepath,text,err=>{
                err ? reject(err) : resolve(text)
            })
         })
     }
 }
fsPromise(fs.writeFileSync,'./data/text.txt','111')
fsPromise(fs.readFile, './data/text.txt')
